package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.Salary;
import cn.wolfcode.crm.query.SalaryQueryObject;
import cn.wolfcode.crm.service.ISalaryService;
import cn.wolfcode.crm.util.JsonResult;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("salary")
public class SalaryController {

    @Autowired
    private ISalaryService salaryService;

    @RequestMapping("")
    public String index(){
        return "salary/salary";
    }

    @RequestMapping("listDir")
    public String listDir(){
        return "salary/listDir";
    }

    @RequestMapping("listSlr")
    public String listSlr(){
        return "salary/list";
    }

    @RequestMapping("list")
    @ResponseBody
    public PageResult list(SalaryQueryObject qo){
        return salaryService.query(qo);

    }
    @RequestMapping("save")
    @ResponseBody
    public JsonResult save(Salary entity){

        try{
            salaryService.save(entity);

        }catch(Exception e){
            e.printStackTrace();
            return new JsonResult("保存失败");
        }

        return new JsonResult();

    }

    }

